package net.homelinux.chaoswg.io.renga.krypto.animations.Add;

import net.homelinux.chaoswg.io.renga.core.animations.State;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.Unsigned128Bit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.Unsigned16Bit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.Unsigned32Bit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.Unsigned64Bit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.Unsigned8Bit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.UnsignedNBit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.UnsignedNBitFactory;

public class AddState implements State {
    UnsignedNBit augend = new Unsigned8Bit();
    UnsignedNBit addend = new Unsigned8Bit();
    UnsignedNBit result = new Unsigned8Bit();

    public AddState () {}
    
    public AddState (UnsignedNBit augend, UnsignedNBit addend) {
        this.augend = augend;
        this.addend = addend;
        
        if (augend instanceof Unsigned8Bit) {
            this.result = new Unsigned8Bit ();
        } else if (augend instanceof Unsigned16Bit) {
            this.result = new Unsigned16Bit ();
            
        }else if (augend instanceof Unsigned32Bit) {
            this.result = new Unsigned32Bit ();
            
        } else if (augend instanceof Unsigned64Bit) {
            this.result = new Unsigned64Bit ();
            
        } else if (augend instanceof Unsigned128Bit) {
            this.result = new Unsigned128Bit ();
        }
    }
    
    public UnsignedNBit getAddend() {
        return addend;
    }
    public void setAddend(UnsignedNBit addend) {
        this.addend = addend;
    }
    public UnsignedNBit getAugend() {
        return augend;
    }
    public void setAugend(UnsignedNBit augend) {
        this.augend = augend;
    }
    public UnsignedNBit getResult() {
        return result;
    }
    public void setResult(UnsignedNBit result) {
        this.result = result;
    }

    public void setOperand(final int slot, final Object value) {
        if (value instanceof UnsignedNBit) {
            switch (slot) {
                case 0:
                    augend = ((UnsignedNBit)value);
                    result = UnsignedNBitFactory.createUnsignedNBitFactory().get(augend.getN());
                    break;
                case 1:
                    addend = ((UnsignedNBit)value);
                    result = UnsignedNBitFactory.createUnsignedNBitFactory().get(addend.getN());
                    break;
            }
        }
    }

}
